import scrapy
from Myspider.items import BaiDuItem

class BaiduSpider(scrapy.Spider):
    name = "baidu"
    allowed_domains = ["baidu.com"]
    start_urls = ["https://baidu.com"]

    def parse(self, response):
        
        res =response.xpath('//*[@id="hotsearch-content-wrapper"]/li/a/span[2]')
        for i in res:
            tit = i.xpath('.//text()').extract()
            myitem =BaiDuItem(title =tit)
            yield myitem
        # for i in res:    
        #     print("抓取的内容为",i)
        # return res